package com.yangit.temp.util.excel.easy.service.impl;


import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import com.yangit.temp.util.excel.easy.service.ITaskService;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;

@Slf4j
@Service
public class TastServiceImpl implements ITaskService {


    @Async("taskExecutor") // 指定线程池，也可以直接写@Async
    public Future<Map<String,Object>> sendMessage3(int i) throws InterruptedException {

        log.info("发送短信方法---- "+i+"   执行开始"+ new Date());
        Thread.sleep(2000); // 模拟耗时
        log.info("发送短信方法---- "+i+"   执行结束" + new Date());
        Map<String,Object> map = new HashMap<>();
        map.put("id",i);
        return new AsyncResult<Map<String,Object>>(map);
    }

    @Async
    @Override
    public void getTest(int i){
        log.debug("I:"+i);
    }
}
